<template>
  <div id="app">
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="SQL">
        <el-input type="textarea" v-model="form.sql" rows="6"></el-input>
      </el-form-item>
      <el-row>
        <el-col :span="3">
          <el-form-item>
            <el-button type="primary" @click="onSubmit">查 询</el-button>
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-form-item label="密码">
            <el-input type="password" v-model="form.password"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
import {Base64} from "js-base64";
import axios from "axios";

export default {
  name: "Sql",
  data() {
    return {
      form: {
        sql: '',
        password: ''
      }
    };
  },
  methods: {
    onSubmit() {
      const sql = this.form.sql;
      const base64Sql = Base64.encode(sql, true);
      const sqlQuery = {"sql": base64Sql, "password": this.form.password}
      const url = 'http://localhost:18180/inner/sql-query';
      axios.post(url, sqlQuery)
          .then(function (response) {
            console.log(response.data.data);
          })
          .catch(function (error) {
            console.log(error);
          })
          .finally(function () {
            // always executed
          });
    }
  }
}
</script>

<style scoped>

</style>
